/**
  ******************************************************************************
  * File Name          : ctrl_common.h
  * Description        : Code for data process applications
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

#ifndef __ctrl_interface_H
#define __ctrl_interface_H

#include <stdint.h>
#include <string.h>

#define CTR_FAN_CHANNEL_ALLNUM       13u
#define CTR_SHL_CHANNEL_ALLNUM       2u
#define CTR_NUQ_CHANNEL_ALLNUM       3u
#define CTR_VFD_CHANNEL_ALLNUM       4u

typedef enum
{
  CTRL_MODE_MU = 0,
  CTRL_MODE_ZN = 1,
  CTRL_MODE_JT = 2,
  CTRL_MODE_DL = 3,
  CTRL_MODE_SK = 4,
}Ctrl_WorkModeType;

typedef struct
{
  uint8_t fnmdsken;
  uint8_t slmdsken;
  uint8_t nqmdsken;
  uint8_t vfmdsken;
  Ctrl_WorkModeType mode;
}Ctrl_ParaMDType;

typedef struct
{
  uint8_t fnsptp;
  uint8_t fnrttp;
  uint8_t fnhin3;
  uint8_t slrttp;
  uint8_t nqfq;
  uint8_t nqrttp;
  int16_t fnhitp;
  int16_t fnlotp;
  int16_t slhitp;
  int16_t sllotp;
  int16_t nqhitp;
  int16_t nqlotp;
  int16_t bjgw;
  int16_t bjdw;
  uint16_t xcfnins;
}Ctrl_ParaJTType;

typedef struct
{
  int16_t fntp[CTR_FAN_CHANNEL_ALLNUM];
  int16_t sltp[CTR_SHL_CHANNEL_ALLNUM];
  int16_t nqtp[CTR_NUQ_CHANNEL_ALLNUM];
  int16_t vftp[CTR_VFD_CHANNEL_ALLNUM];
}Ctrl_ParaDL1Type;

typedef struct
{
  uint8_t fnrttp;
  uint8_t slrttp;
  uint8_t nqfq;
  uint8_t nqrttp;
}Ctrl_ParaDL2Type;

typedef struct
{
  uint8_t  fnen;
  uint8_t  fntd[CTR_FAN_CHANNEL_ALLNUM];
  
  uint8_t  slen;
  uint8_t  sltd[CTR_SHL_CHANNEL_ALLNUM];
  
  uint8_t  nqen;
  uint8_t  nqtd[CTR_NUQ_CHANNEL_ALLNUM];
  
  uint8_t  vfen;
  uint8_t  vftf[CTR_VFD_CHANNEL_ALLNUM];
  uint8_t  vfjs[CTR_VFD_CHANNEL_ALLNUM];
  
  uint16_t fnkq;
  uint16_t fngb;
  uint16_t slkq;
  uint16_t slgb;
  uint16_t nqkq;
  uint16_t nqgb;
  uint16_t vfkq[CTR_VFD_CHANNEL_ALLNUM];
  uint16_t vfgb[CTR_VFD_CHANNEL_ALLNUM];
}Ctrl_ParaSKType;

typedef struct
{
  uint8_t fntd[CTR_FAN_CHANNEL_ALLNUM];
  uint8_t sltd[CTR_SHL_CHANNEL_ALLNUM];
  uint8_t nqtd[CTR_NUQ_CHANNEL_ALLNUM];
  uint8_t vftd[CTR_VFD_CHANNEL_ALLNUM];
  uint8_t bjtd;
  uint8_t zdtd;
  uint8_t zden;
}Ctrl_ParaTDType;


typedef struct
{
  volatile char fnst[CTR_FAN_CHANNEL_ALLNUM];
}Ctrl_StateFNType;

typedef struct
{
	volatile char slst[CTR_SHL_CHANNEL_ALLNUM];
}Ctrl_StateSLType;

typedef struct
{
	volatile char nqst[CTR_NUQ_CHANNEL_ALLNUM];
}Ctrl_StateNQType;

typedef struct
{
	volatile char vfst[CTR_VFD_CHANNEL_ALLNUM];
	volatile char vfjs[CTR_VFD_CHANNEL_ALLNUM];
}Ctrl_StateVFType;

/* 传感器数据 */
typedef struct
{
	volatile uint8_t  humidity;
	volatile uint8_t  nh3;
  volatile uint16_t flag;
	volatile int16_t  temperature;
  volatile uint16_t co2;
	volatile uint16_t tvoc;
	volatile int16_t  pressure;
}Collector_DataType;

extern uint8_t Ctr_CheckStateCorrect(const char c);
extern uint8_t Ctr_CheckMDPara(Ctrl_ParaMDType *para);
extern uint8_t Ctr_CheckJTPara(Ctrl_ParaJTType *para);
extern uint8_t Ctr_CheckDL1Para(Ctrl_ParaDL1Type *para);
extern uint8_t Ctr_CheckDL2Para(Ctrl_ParaDL2Type *para);
extern uint8_t Ctr_CheckSKPara(Ctrl_ParaSKType *para);
extern uint8_t Ctr_CheckTDPara(Ctrl_ParaTDType *para);

#endif /* __ctrl_interface_H */
